package com.lg.atp.sercurity;


import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import org.springframework.security.access.AccessDeniedException;
import org.springframework.security.core.Authentication;
import org.springframework.security.web.DefaultRedirectStrategy;
import org.springframework.security.web.RedirectStrategy;
import org.springframework.security.web.authentication.AuthenticationSuccessHandler;


public class MySuccessHandler implements AuthenticationSuccessHandler {
	
	
	private String defaultTargetUrl;  
	      
	private RedirectStrategy redirectStrategy = new DefaultRedirectStrategy();
	@Override
	public void onAuthenticationSuccess(HttpServletRequest request,
			HttpServletResponse response, Authentication authentication) throws IOException,
			ServletException {
		    HttpSession session = request.getSession();
		    session.removeAttribute("SPRING_SECURITY_LAST_EXCEPTION");
		    session.removeAttribute("SPRING_SECURITY_403_EXCEPTION");
			this.redirectStrategy.sendRedirect(request, response, this.defaultTargetUrl);  
	}
	
	


	public void setDefaultTargetUrl(String defaultTargetUrl) {
		this.defaultTargetUrl = defaultTargetUrl;
	}


  

}
